<?php
namespace Admin\Controller;
use Think\Controller;
class RegisterController extends Controller {
    public function Register(){
        if(IS_POST){
            $code=I('code');
            $verify = new \Think\Verify();
            $bool= $verify->check($code);
            if(!$bool){
                $this->error('验证码输入错误！');
                exit();
            }
            
                $user =D('user');
                $data = $user->create($_POST);
                if (!$data){
                    $this->error($user->getError());
                }
                else {
                    $num = $user->add($data);
                    if($num){
                        $this->success('注册成功！',U('login/login'));
                    }
                    else {
                        $this->error('注册失败！');
                    }
                }    
        }
        else {
            $this->display();
        }
        
    }
    public function Code(){
        $config =    array(
        'fontSize'    =>    30,    // 验证码字体大小
        'length'      =>    4,     // 验证码位数
        'useNoise'    =>    false,
        'imageW'      =>  320,
        );
        $Verify =     new \Think\Verify($config);
        $Verify->entry();
    }
}